package com.own.component.common.util;

import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

/**
 * UrlUtil
 *
 * @author chenxueli
 * @date 2021/3/27 19:19
 */
public final class UrlUtil {

    /**
     * url中替换特殊字符
     *
     * @param url url地址
     * @return 新的url
     */
    public static String specialUrlEncode(String url) {
        return URLEncoder.encode(url, StandardCharsets.UTF_8)
                .replace("+", "%20")
                .replace("*", "%2A")
                .replace("%7E", "~");
    }

}
